package com.eight.cloud.mybatisplus.method;

import com.baomidou.mybatisplus.core.injector.AbstractMethod;
import com.baomidou.mybatisplus.core.metadata.TableInfo;
import com.eight.cloud.mybatisplus.annotation.enums.MpSqlMethod;
import org.apache.ibatis.mapping.MappedStatement;

/**
 * @ClassName: RealDeleteById
 * @Author: TXC
 * @Date: 2024-12-19 11:18
 **/
public class RealDeleteById extends AbstractMethod {
    public RealDeleteById() {
        this(MpSqlMethod.REAL_DELETE_BY_ID.getMethod());
    }

    /**
     * @param name 方法名
     * @since 3.5.0
     */
    public RealDeleteById(String name) {
        super(name);
    }

    @Override
    public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
        MpSqlMethod sqlMethod = MpSqlMethod.REAL_DELETE_BY_ID;
        return this.addDeleteMappedStatement(mapperClass, methodName, super.createSqlSource(configuration,
                String.format(sqlMethod.getSql(), tableInfo.getTableName(), tableInfo.getKeyColumn(),
                tableInfo.getKeyProperty()), Object.class));
    }
}
